﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ks.Fs.Entity;
using System.Data;

namespace Ks.Fs.Core.Data.SqlDataProvider.Mapper
{
    public class FolderMapper : GenericMapper<Folder>
    {
        protected override Folder MapOne(IDataRecord record)
        {
            Folder obj = new Folder();

            if (record["Id"] != DBNull.Value)
            {
                obj.Id = Convert.ToInt32(record["Id"]);
            }

            if (record["Name"] != DBNull.Value)
            {
                obj.FolderName = Convert.ToString(record["Name"]);
            }

            if (record["Path"] != DBNull.Value)
            {
                obj.Path = Convert.ToString(record["Path"]);
            }

            if (record["Owner"] != DBNull.Value)
            {
                obj.Owner = Convert.ToString(record["Owner"]);
            }

            if (record["IsPublic"] != DBNull.Value)
            {
                obj.IsPublic = Convert.ToBoolean(record["IsPublic"]);
            }

            if (record["ParentId"] != DBNull.Value)
            {
                obj.ParentId = Convert.ToInt32(record["ParentId"]);
            }            

            return obj;
        }
    }
}
